<?php
declare (strict_types = 1);

namespace app\command;

use app\api\controller\h5_dianpu\Baihuo;
use app\api\repository\DianpuSaleRepository;
use app\model\zs\ZsMemberCoupon;
use app\model\zs\ZsMemberCouponProvide;
use Exception;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\Db;

class DianpuSale extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('dianpu:sale')
            ->setDescription('移动端店铺销售数据写入')
            ->addArgument('type', Argument::REQUIRED, '可选类型: amount, ratio')
            ->addOption('year', null, Option::VALUE_REQUIRED, '年份');
    }

    protected function execute(Input $input, Output $output)
    {
        $type = $input->getArgument('type');
        $year = $input->getOption('year');

        $dianpu_sale = new DianpuSaleRepository();
        if ($type == 'amount') {
            $dianpu_sale->createDataByYear($year);
            $output->info('type = month');
        }
        if ($type == 'ratio') {
            $dianpu_sale->updateRatioByYear($year);
            $output->info('222');
        }
        $output->info('end');
    }
}
